#!/bin/sh
## setup RTC time
hwclock -s -f /dev/rtc1
hwclock -w
## setup PWM using device
cd /sys/class/pwm/pwmchip0
if [ ! -d pwm0 ]; then
	echo 0 > export
fi
if [ ! -d pwm1 ]; then
	echo 1 > export
fi
cd pwm0
echo 1000000 > period
echo inversed > ../pwm1/polarity
echo 1000000 > ../pwm1/period
echo 0 > enable
echo 0 > ../pwm1/enable
## setup all GPIOs
cd /sys/class/gpio
if [ ! -d gpio30 ]; then
	echo 30 > export
fi
if [ ! -d gpio31 ]; then
	echo 31 > export
fi
if [ ! -d gpio48 ]; then
	echo 48 > export
fi
if [ ! -d gpio113 ]; then
	echo 113 > export
fi
if [ ! -d gpio111 ]; then
	echo 111 > export
fi
if [ ! -d gpio112 ]; then
	echo 112 > export
fi
if [ ! -d gpio110 ]; then
	echo 110 > export
fi
if [ ! -d gpio3 ]; then
	echo 3 > export
fi
if [ ! -d gpio2 ]; then
	echo 2 > export
fi
if [ ! -d gpio60 ]; then
	echo 60 > export
fi
echo in > gpio30/direction
echo in > gpio31/direction
echo in > gpio48/direction
echo in > gpio3/direction
echo out > gpio113/direction
echo out > gpio111/direction
echo out > gpio112/direction
echo out > gpio110/direction
echo out > gpio60/direction
echo 0 > /sys/class/gpio/gpio60/value
echo 0 > /sys/class/gpio/gpio113/value
echo 0 > /sys/class/gpio/gpio111/value
echo 1 > /sys/class/gpio/gpio112/value

########
/etc/init.d/networking restart
ifconfig eth0 10.1.20.123 netmask 255.255.255.0 broadcast 10.1.20.255

/home/root/upgrade.sh
